#include "StdAfx.h"
#include "ConsumerWorkModel.h"


ConsumerWorkModel::ConsumerWorkModel(void)
{
	m_id = -1;
	m_consumerID = -1;
	m_workType = -1;
	m_companyName = _T("");
	m_duty = -1;
	m_monthlySalary = -1;
	m_workTime = -1;
	m_payForm = -1; 
	m_socialSecurityBase = -1;
	m_reservedFundsBase = -1;
}

ConsumerWorkModel::~ConsumerWorkModel(void)
{
}

ConsumerWorkModel& ConsumerWorkModel::operator=(const ConsumerWorkModel& infoModel)
{
	m_id = infoModel.m_id;
	m_consumerID = infoModel.m_consumerID;
	m_workType = infoModel.m_workType;
	m_companyName = infoModel.m_companyName;
	m_duty = infoModel.m_duty;
	m_monthlySalary = infoModel.m_monthlySalary;
	m_workTime = infoModel.m_workTime;
	m_payForm = infoModel.m_payForm; 
	m_socialSecurityBase = infoModel.m_socialSecurityBase;
	m_reservedFundsBase = infoModel.m_reservedFundsBase;

	return *this;
}

void ConsumerWorkModel::parseFromJson(Json::Value& jsonData)
{
	if (!jsonData["professionType"].isNull()) 
	{
		this->m_workType = jsonData["professionType"].asInt();
	}
	CUtils::getJsonStringField(jsonData, "comName", m_companyName);
	if (!jsonData["position"].isNull()) 
	{
		this->m_duty = jsonData["position"].asInt();
	}
	if (!jsonData["monthlySalary"].isNull()) 
	{
		this->m_monthlySalary = jsonData["monthlySalary"].asInt();
	}
	if (!jsonData["workTime"].isNull()) 
	{
		this->m_workTime = jsonData["workTime"].asInt();
	}
	if (!jsonData["payType"].isNull()) 
	{
		this->m_payForm = jsonData["payType"].asInt();
	}
	if (!jsonData["sbBase"].isNull()) 
	{
		this->m_socialSecurityBase = jsonData["sbBase"].asInt();
	}
	if (!jsonData["gjjBase"].isNull()) 
	{
		this->m_reservedFundsBase = jsonData["gjjBase"].asInt();
	}
}

void ConsumerWorkModel::toJson(Json::Value& jsonData)
{
	if (this->m_workType >= 0) 
	{
		jsonData["professionType"] = this->m_workType;
	}
	if (this->m_companyName.GetLength() >= 0) 
	{
		jsonData["comName"] = this->m_companyName.GetBuffer();
	}
	if (this->m_duty >= 0) 
	{
		jsonData["position"] = this->m_duty;
	}
	if (this->m_monthlySalary >= 0) 
	{
		jsonData["monthlySalary"] = this->m_monthlySalary;
	}
	if (this->m_workTime >= 0) 
	{
		jsonData["workTime"] = this->m_workTime;
	}
	if (this->m_payForm >= 0) 
	{
		jsonData["payType"] = this->m_payForm;
	}
	if (this->m_socialSecurityBase >= 0) 
	{
		jsonData["sbBase"] = this->m_socialSecurityBase;
	}
	if (this->m_reservedFundsBase >= 0) 
	{
		jsonData["gjjBase"] = this->m_reservedFundsBase;
	}
}
